package com.ruibang.glass.quality.constant;

import com.teaming.cloud.framework2.common.exception.ServiceException;

import java.text.SimpleDateFormat;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.List;

public class Constants {
    public static final Integer ZERO_INT = 0;

    public static final Integer ONE_INT = 1;

    public static final String ZERO_STR = "0";

    public static final String ONE_STR = "1";

    public static final String TWO_STR = "2";

    public static final String THREE_STR = "3";

    public static final String FOUR_STR = "4";

    public static final String FIVE_STR = "5";

    public static final String SIX_STR = "6";

    public static final String GRADE_A = "A";
    public static final String GRADE_B = "B";
    public static final String GRADE_C = "C";

    public static final Integer DEFECT_DEFAULT_QUERY_DAYS = 4;

    public static final String COORDINATE_X = "X";
    public static final String COORDINATE_Y = "Y";
    public static final String OPEN_BUBBLE = "Open Bubble";
    public static final String PT = "PT";
    public static final String BUBBLE = "Bubble";
    public static final String STONE = "Stone";
    public static final String NG = "NG";
    public static final String OK = "OK";

    public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");

    //铂金缺陷
    public static final String DEFECT_PT = "PT";
    //气泡缺陷
    public static final String DEFECT_BUBBLE = "Bubble";
    //结石缺陷
    public static final String DEFECT_STONE = "Stone";
    //总缺陷字段类型
    public static final String DEFECT_DICT_GROUP_TYPE = "defect_total";

    private static final String DEFECT_ADG = "ADG";


    public static final String COLD_GLASS_ID_PREFIX = "SL0120";
    public static final String GLASS_POINT_DEFECT_S = "S";
    public static final String GLASS_POINT_DEFECT_M = "M";
    public static final String GLASS_POINT_DEFECT_L = "L";
    public static final String GLASS_POINT_DEFECT_OL = "OL";
    public static final String GLASS_POINT_DEFECT_SB = "S_B";
    public static final String GLASS_POINT_DEFECT_MB = "M_B";
    public static final String GLASS_POINT_DEFECT_LB = "L_B";
    public static final String GLASS_POINT_DEFECT_OLB = "OL_B";
    public static final String GLASS_POINT_DEFECT_SUM_A = "SUM_A";
    public static final String GLASS_POINT_DEFECT_SUM_B = "SUM_B";
    public static final String GLASS_POINT_DEFECT_SUM_AB = "SUM_AB";
    public static final List<String> GLASS_POINT_DEFECT_LIST = Arrays.asList(GLASS_POINT_DEFECT_S, GLASS_POINT_DEFECT_M, GLASS_POINT_DEFECT_L, GLASS_POINT_DEFECT_OL, GLASS_POINT_DEFECT_SB, GLASS_POINT_DEFECT_MB, GLASS_POINT_DEFECT_LB, GLASS_POINT_DEFECT_OLB);
    public static final String[] ZD_HEADERS = {"ID", "S(1-3um)", "M(3-5um)", "L(5-10um)", "OL(10-50um)", "总数", "规格(A+B)", "S", "M", "L", "OL", "A面合计", "S_B", "M_B", "L_B", "OL_B", "B面合计"};
    public static final String[] TOTAL_AB_TABLE_HEADERS = {"玻璃ID", "缺陷名称", "X", "Y"};
    public static final String[] DEFECT_DETAIL_TABLE_HEADERS = {"玻璃ID", "缺陷名称", "检查时间", "横切时间", "大小", "层别", "X", "Y"};

    public static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");


    /**
     * @author songJinKang
     * @version v1.0
     * @Description: 玻璃种类
     * @date 2023-12-12 14:35
     */
    public enum GlassGrade {
        DUMMY(0, "Dummy"),
        TFT(1, "TFT"),
        CF(2, "CF");

        private int code;
        private String name;

        GlassGrade(int code, String name) {
            this.code = code;
            this.name = name;
        }

        public String getName() {
            return name;
        }

        public int getCode() {
            return code;
        }

        public static int getCodeByName(String name) {
            for (GlassGrade e : GlassGrade.values()) {
                if (e.getName().equals(name)) {
                    return e.getCode();
                }
            }
            throw new ServiceException(QualityErrorCode.UNKNOWN_GLASS_GRADE.getCode(), QualityErrorCode.UNKNOWN_GLASS_GRADE.getMsg());
        }
    }
}
